package crawler;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;

public class CrawlerDocument {
	private URL _url;
	private URL _seed;
	private HashMap<String, Object> _features;
	private ArrayList<CrawlerDocument> _outlinkDocs;
	
	private void Init(){
		this._features = new HashMap<String, Object>();
		this._outlinkDocs = new ArrayList<CrawlerDocument>();
	}
	
	public CrawlerDocument(){
		this.Init();
	}
	
	public CrawlerDocument(String url) throws MalformedURLException {
		this.Init();
		this._url = new URL(url);
	}
	
	public CrawlerDocument(String url, String seed) throws MalformedURLException{
		this.Init();
		this._url = new URL(url);
		this._seed = new URL(seed);
	}
	
	public void setUrl(URL url){
		this._url = url;
	}
	
	public URL getUrl(){
		return this._url;
	}
	
	public void setUrl(String url) throws MalformedURLException{
		this._url = new URL(url);
	}
	
	public String getUrlStr(){
		return this._url.toString();
	}
	
	public void setSeed(String seed) throws MalformedURLException{
		this._seed = new URL(seed);
	}
	
	public String getSeed(){
		return this._seed.toString();
	}
	
	public void setFeatures(HashMap<String, Object> features){
		this._features = features;
	}
	
	public HashMap<String, Object> getFeatures(){
		return this._features;
	}
	
	public void addFeature(String key, Object value){
		this._features.put(key, value);
	}
	
	public Object getFeature(String key){
		return this._features.get(key);
	}
	
	public void addOutlinkDoc(CrawlerDocument outlink){
		this._outlinkDocs.add(outlink);
	}
	
	public ArrayList<CrawlerDocument> getOutlinks(){
		return this._outlinkDocs;
	}
	
}
